package com.yuqian.JavaSe.java.sreflect;

import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
import java.util.Properties;

public class SConstructor {

	public static void main(String[] args) {
		Class<Student> student = Student.class;
		Constructor[] cons= student.getDeclaredConstructors();
		for(Constructor constructor:cons){
			StringBuilder sb = new  StringBuilder();
			//constructor.getAnnotations();
			int modifier = constructor.getModifiers();
			sb.append(Modifier.toString(modifier));
			sb.append(" ");
			sb.append(constructor.getName()+" (");
			Class[] paType =constructor.getParameterTypes();
			for(Class type:paType){
				sb.append(type.getName()+", ");
			}
			sb.deleteCharAt(sb.lastIndexOf(","));
			sb.append(")");
			System.out.println(sb.toString());
		}
		
		Properties po = new Properties();
		try{
			throw new NullPointerException();
		}catch(RuntimeException e){
			e.printStackTrace();
			System.out.println("asgaga");
		}
	}
	
}

class Student{
	private String name;
	private int age;
	private Sex sex;
	
	/**
	 * 构造器
	 * @param name
	 * @param age
	 * @param sex
	 */
	public Student(String name,int age,Sex sex){
		this.name =name;
		this.age = age;
		this.sex = sex;
	}
	
	public void getStudentInfo(){
		System.out.println("name:"+this.name);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public Sex getSex() {
		return sex;
	}

	public void setSex(Sex sex) {
		this.sex = sex;
	}
	
	
}

enum Sex{
	Male("男"),Famale("女");
	
	private String sex;
	private Sex(String sex){
		this.sex =sex;
	}
	
	public String getSexDescribe(){
		return sex;
	}
}
